﻿using System;
using static Sgs.Model.Player;
using static Sgs.Utils.Method;

namespace Sgs.Mode
{
    class Identity
    {
        public class GamePattern
        {
            public int PlayerCount;
            public string ModeName;
            public PlayerIdentity[] CampList;

            public GamePattern(string ModeName, int PlayerCount, PlayerIdentity[] CampList)
            {
                this.PlayerCount = PlayerCount;
                this.ModeName = ModeName;
                this.CampList = CampList;
            }

            public PlayerIdentity[] ProvideCampList()
            {
                PlayerIdentity[] campList = (PlayerIdentity[])CampList.Clone();
                campList = Shuffle(campList);
                return campList;
            }
        }

        public enum PatternOptions
        {
            Player5, Player8
        }

        public readonly GamePattern[] Pattern = new GamePattern[]
        {
                new GamePattern("五人局", 5, new PlayerIdentity[] {PlayerIdentity.忠臣, PlayerIdentity.反贼, PlayerIdentity.反贼, PlayerIdentity.内奸 }),
                new GamePattern("八人局", 8, new PlayerIdentity[] {PlayerIdentity.忠臣, PlayerIdentity.忠臣, PlayerIdentity.反贼, PlayerIdentity.反贼, PlayerIdentity.反贼, PlayerIdentity.反贼, PlayerIdentity.内奸 })
        };

        public GamePattern this[PatternOptions options]
        {
            get
            {
                int index = (int)options;
                if (0 <= index && index < Pattern.Length)
                {
                    return Pattern[index];
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
            }
        }
    }
}

